<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>计算年龄</title>
  </head>
  <body>
    <script>
      // 根据用户输入的年份，和系统当前年份，计算出用户多大了
      var year = prompt('请输入你的出生年份：');
      var age = new Date().getFullYear() - year;
      alert('你今年 ' + age + ' 岁了');
    </script>
  </body>
</html>
